import React from 'react';
import { ICard } from './types';
import { move, out, log_msg, add_fruits, flip_card } from './Game';

import lemon_img from './images/柠檬.png';
import archive_img from './images/存档.png';
import archive_score_img from './images/存档得分.png';
import big_archive_img from './images/大存档.png';
import tomato_img from './images/番茄.png';
import zoom_img from './images/观星.png';
import zoom_score_img from './images/观星得分.png';
import big_zoom_img from './images/大观星.png';
import juice_img from './images/果汁.png';
import shield_img from './images/护甲.png';
import printer_img from './images/打印机.png';
import night_img from './images/集体存档.png';
import beer_img from './images/啤酒.png';
import apple_img from './images/苹果.png';
import salad_img from './images/沙拉.png';
import shit_img from './images/屎.png';
import double_shit_img from './images/二屎.png';
import triple_shit_img from './images/三屎.png';
import camera_img from './images/相机.png';
import bomb_img from './images/炸弹.png';
import soccer_img from './images/足球.png';
import pleft_img from './images/左向.png';
import pright_img from './images/右向.png';
import shoe_img from './images/鞋子.png';
import sword_img from './images/果汁得分.png';
import burger_img from './images/白嫖.png';
import big_burger_img from './images/大白嫖.png';
import plane_img from './images/飞机.png';
import fire_img from './images/引爆.png';
import big_printer_img from './images/大打印机.png';
import turtle_img from './images/乌龟.png';
import turtle_score_img from './images/乌龟得分.png';
import big_turtle_img from './images/大乌龟.png';
// import double_juice_img from './images/大果汁.png';

export const CARDS: ICard[] = [
  {
    name: "炸弹",
    desc: "嘣！",
    effect_type: "aggressive",
    illust: bomb_img,
    card_id: 0,
    effect(G, ctx, player) {
      out(G, player);
    },
  },
  {
    name: "护甲",
    desc: "放入持续区，可抵挡1次出局",
    effect_type: "protective",
    // has_fruit: true,
    illust: shield_img,
    card_id: 1,
    effect(G, ctx, player) {
      player.entities.push("shield");
    },
  },
  // {
  //   name: "吉他",
  //   desc: "如果你的鞋子未使用，则横置鞋子，获得3分，否则重置鞋子",
  //   effect_type: "greedy",
  //   // has_fruit: true,
  //   illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/guitar_1f3b8.png",
  //   effect(G, ctx, player) {
  //     // player.score += 1;
  //     if (player.entities.includes("skip")) {
  //       player.entities = player.entities.filter(x => (x !== "skip"));
  //       player.score += 3;
  //     }
  //     else {
  //       player.entities.push("skip");
  //     }
  //   },
  // },
  {
    name: "足球",
    desc: "获得1分；这张牌被踹掉时，获得3分",
    effect_type: "greedy",
    has_fruit: true,
    illust: soccer_img,
    effect(G, ctx, player) {
      player.score += 1;
      // if (player.entities.includes("skip")) {
      //   player.entities = player.entities.filter(x => (x !== "skip"));
      //   player.score += 3;
      // }
      // else {
      //   player.entities.push("skip");
      // }
    },
    onFlip(G, ctx, player) {
      player.score += 2;
    }
  },
{
    name: "屎",
    desc: "如果你至少有5分，则失去1分，否则获得1分",
    // has_fruit: true,
    effect_type: "topdown",
    illust: shit_img,
    effect(G, ctx, player) {
      if (player.score >= 5) {player.score -= 1;}
      else {player.score += 1;}
    },
  },

{
    name: "二屎",
    desc: "如果你至少有6分，则失去2分，否则获得2分",
    // has_fruit: true,
    effect_type: "topdown",
    is_reinforced: true,
    // illust: double_shit_img,
    illust: shit_img,
    card_id: 2,
    effect(G, ctx, player) {
      if (player.score >= 6) {player.score -= 2;}
      else {player.score += 2;}
    },
  },

{
    name: "三屎",
    desc: "如果你至少有5分，则失去3分，否则获得3分",
    // has_fruit: true,
    effect_type: "topdown",
    illust: triple_shit_img,
    is_reinforced: true,
    effect(G, ctx, player) {
      if (player.score >= 5) {player.score -= 3;}
      else {player.score += 3;}
    },
  },

{
    name: "猴子",
    desc: "如果你没有水果，则获得3分",
    has_fruit: true,
    effect_type: "greedy",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/fish_1f41f.png",
    effect(G, ctx, player) {
      let fruit = player.entities.find(x => typeof x == "object");
      if (fruit === undefined) {
        player.score += 3;
      }
    },
  },

{
    name: "裸奔",
    desc: "弃掉持续区的所有牌",
    // has_fruit: true,
    effect_type: "topdown",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/google/263/man-running_1f3c3-200d-2642-fe0f.png",
    effect(G, ctx, player) {
      player.entities = [];
    },
  },

{
    name: "马桶",
    desc: "如果你的弃牌堆中，有炸弹或粪便，则获得2分",
    has_fruit: true,
    effect_type: "greedy",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/toilet_1f6bd.png",
    effect(G, ctx, player) {
      // player.entities = [];
      let bad_card = player.discard.find(c => (c.name === "炸弹" || c.name === "美味佳肴"));
      if (bad_card !== undefined) {
        player.score += 2;
      }
    },
  },

  {
    name: "送温暖",
    desc: "你的上家和下家获得1分(如果存活的话)",
    effect_type: "greedy",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/pot-of-food_1f372.png",
    effect(G, ctx, player) {
      let idx = G.players.indexOf(player);
      let upper_idx = (idx + 1) % 4;
      let lower_idx = (idx + 3) % 4;
      let upper_player = G.players[upper_idx];
      let lower_player = G.players[lower_idx];
      if (!upper_player.out) {
        upper_player.score += 1;
      }
      if (!lower_player.out) {
        lower_player.score += 1;
      }
    }
  },

{
    name: "右向",
    desc: "你的右家得1分",
    effect_type: "greedy",
    illust: pright_img,
    effect(G, ctx, player) {
      let idx = G.players.indexOf(player);
      let upper_idx = (idx + 1) % 4;
      let lower_idx = (idx + 3) % 4;
      let upper_player = G.players[upper_idx];
      let lower_player = G.players[lower_idx];
      // if (!lower_player.out) {
        lower_player.score += 1;
      // }
    }
  },

{
    name: "左向",
    desc: "你的左家得1分",
    effect_type: "greedy",
    illust: pleft_img,
    effect(G, ctx, player) {
      let idx = G.players.indexOf(player);
      let upper_idx = (idx + 1) % 4;
      let lower_idx = (idx + 3) % 4;
      let upper_player = G.players[upper_idx];
      let lower_player = G.players[lower_idx];
      // if (!upper_player.out) {
        upper_player.score += 1;
      // }
    }
  },


  {
    name: "乌龟",
    desc: "本回合如果你存活到最后，则获得1分",
    effect_type: "greedy",
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/turtle_1f422.png",
    illust: turtle_img,
    // has_fruit: true,
    card_id: 7,
    effect(G, ctx, player) {
      player.entities.push("turtle");
    }
  },
  {
    name: "大乌龟",
    desc: "本回合如果你存活到最后，则获得2分",
    effect_type: "greedy",
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/turtle_1f422.png",
    illust: big_turtle_img,
    is_reinforced: true,
    // has_fruit: true,
    effect(G, ctx, player) {
      player.entities.push("turtle");
      player.entities.push("turtle");
    }
  },
  {
    name: "超级乌龟",
    desc: "本回合如果你存活到最后，则获得3分",
    effect_type: "greedy",
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/turtle_1f422.png",
    illust: plane_img,
    is_reinforced: true,
    // has_fruit: true,
    effect(G, ctx, player) {
      player.entities.push("turtle");
      player.entities.push("turtle");
      player.entities.push("turtle");
    }
  },
  {
    name: "乌龟得分",
    desc: "获得1分，本回合如果你存活到最后，则获得2分",
    effect_type: "greedy",
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/turtle_1f422.png",
    illust: turtle_score_img,
    is_reinforced: true,
    has_fruit: true,
    effect(G, ctx, player) {
      player.score += 1;
      player.survive_bonus += 2;
      player.entities.push("turtle");
    }
  },
  {
    name: "闪电",
    desc: "本回合公共目标分值+2",
    effect_type: "greedy",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/high-voltage_26a1.png",
    has_fruit: false,
    effect(G, ctx, player) {
      G.public_goal_bonus += 2;
    }
  },

  // {
  //   name: "礼物",
  //   desc: "如果你因为炸弹出局，获得2分",
  //   effect_type: "greedy",
  //   has_fruit: true,
  //   illust: "",
  //   effect(G, ctx, player) {
  //     player.entities.push("gift");
  //   }
  // },

  {
    name: "披萨",
    desc: "本回合剩余时间内，你每获得1个水果，就获得1分",
    effect_type: "greedy",
    has_fruit: true,
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/pizza_1f355.png",
    effect(G, ctx, player) {
      player.fruit_bonus += 1;
    }
  },

  {
    name: "番茄",
    desc: "获得1分",
    illust: tomato_img,
    effect_type: "greedy",
    super_fruit: 0,
    has_fruit: true,
    card_id: 6,
    fruit: 0,
    effect(G, ctx, player) {
      player.score += 1;
      // let fruit_types = player.entities.map(fruit => {
      //   if (typeof fruit == "object") {
      //     return fruit.fruit;
      //   }
      //   else {
      //     return undefined;
      //   }
      // });
      // let fruit_set = new Set(fruit_types.filter(x => x !== undefined));
      // if (fruit_set.has(0)) {
      //   player.score += 4;
      // }
      // player.score += fruit_types.filter(x => x === 0).length * 3;
    },
  },

  {
    name: "柠檬",
    desc: "获得1分",
    illust: lemon_img,
    effect_type: "greedy",
    super_fruit: 1,
    has_fruit: true,
    card_id: 6,
    fruit: 1,
    effect(G, ctx, player) {
      player.score += 1;
      // let fruit_types = player.entities.map(fruit => {
      //   if (typeof fruit == "object") {
      //     return fruit.fruit;
      //   }
      //   else {
      //     return undefined;
      //   }
      // });
      // let fruit_set = new Set(fruit_types.filter(x => x !== undefined));
      // if (fruit_set.has(1)) {
      //   player.score += 4;
      // }
      // player.score += fruit_types.filter(x => x === 1).length * 3;
    },
  },

  {
    name: "苹果",
    desc: "获得1分",
    illust: apple_img,
    effect_type: "greedy",
    super_fruit: 2,
    fruit: 2,
    card_id: 6,
    has_fruit: true,
    effect(G, ctx, player) {
      player.score += 1;
      // let fruit_types = player.entities.map(fruit => {
      //   if (typeof fruit == "object") {
      //     return fruit.fruit;
      //   }
      //   else {
      //     return undefined;
      //   }
      // });
      // let fruit_set = new Set(fruit_types.filter(x => x !== undefined));
      // if (fruit_set.has(2)) {
      //   player.score += 4;
      // }
      // player.score += fruit_types.filter(x => x === 2).length * 3;
    },
  },


  
//   {
//     name: "番茄",
//     desc: "获得1分",
//     illust: tomato_img,
//     effect_type: "greedy",
//     super_fruit: 0,
//     effect(G, ctx, player) {
//       player.score += 1;
//     }
//   },

// {
//     name: "柠檬",
//     desc: "获得1分",
//     illust: lemon_img,
//     effect_type: "greedy",
//     super_fruit: 1,
//     effect(G, ctx, player) {
//       player.score += 1;
//     }
//   },

//   {
//     name: "苹果",
//     desc: "获得1分",
//     illust: apple_img,
//     effect_type: "greedy",
//     super_fruit: 2,
//     effect(G, ctx, player) {
//       player.score += 1;
//     }
//   },




  {
    name: "集体拆弹",
    desc: "所有其他玩家查看牌库顶的1张牌，如果是炸弹则弃掉，然后每有1个弃掉炸弹的玩家，你就获得2分",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/cityscape-at-dusk_1f306.png",
    effect(G, ctx, player) {
      let other_players = G.players.filter(x => x != player && !x.out);
      for (let p of other_players) {
        // let flipped = flip_card(p);
        let top_card = p.deck[0];
        if (top_card && top_card.name == "炸弹") {
          move(p.deck, p.discard);
          player.score += 2;
        }
      }
    }
  },
  {
    name: "集体引爆",
    desc: "所有其他玩家弃掉牌库顶的1张牌，弃掉炸弹的玩家出局，然后每有1个因此出局的玩家，就失去2分",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/collision_1f4a5.png",
    effect(G, ctx, player) {
      let other_players = G.players.filter(x => x != player && !x.out);
      for (let p of other_players) {
        let flipped = flip_card(p);
        if (flipped && flipped.name == "炸弹") {
          // out(p);
          player.score -= 2;
        }
      }
    }
  },
  {
    name: "集体存档",
    desc: "所有其他玩家存档1张牌",
    illust: night_img,
    effect_type: "protective",
    effect(G, ctx, player) {
      let other_players = G.players.filter(x => x != player && !x.out);
      for (let p of other_players) {
        move(p.deck, p.hand);
      }
    }
  },
  {
    name: "白嫖",
    desc: "获得3分",
    illust: burger_img,
    effect_type: "greedy",
    has_fruit: false,
    card_id: 6,
    effect(G, ctx, player) {
      player.score += 3;
    }
  },
  {
    name: "大白嫖",
    desc: "获得3分",
    illust: big_burger_img,
    is_reinforced: true,
    effect_type: "aggressive",
    effect(G, ctx, player) {
      player.score += 3;
    }
  },
  {
    name: "鞋子",
    desc: "获得1次跳过机会",
    has_fruit: true,
    effect_type: "protective",
    illust: shoe_img,
    effect(G, ctx, player) {
      player.entities.push("skip");
    }
  },
{
    name: "存档",
    desc: "存档1张牌",
    has_fruit: true,
    effect_type: "protective",
    illust: archive_img,
    card_id: 3,
    effect(G, ctx, player) {
      move(player.deck, player.hand);
    },
  },
  {
    name: "存档得分",
    desc: "存档1张牌，获得2分",
    has_fruit: true,
    // fruit: 0,
    effect_type: "protective",
    illust: archive_score_img,
    is_reinforced: true,
    effect(G, ctx, player) {
      move(player.deck, player.hand);
      player.score += 1;
    },
  },
  {
    name: "圣剑",
    desc: "如果你是庄家，失去1分，否则获得1分",
    effect_type: "topdown",
    illust: sword_img,
    effect(G, ctx, player) {
      if (player.is_dealer) {
        player.score -= 1;
      }
      else {
        player.score += 1;
      }
    }
  },
{
    name: "大存档",
    desc: "存档2张牌",
    has_fruit: true,
    effect_type: "protective",
    illust: big_archive_img,
    is_reinforced: true,
    effect(G, ctx, player) {
      move(player.deck, player.hand);
      move(player.deck, player.hand);
    },
  },

{
    name: "天妇罗",
    desc: "如果这是你本回合第1/2/3次执行此效果，则获得1/3/5分",
    has_fruit: true,
    effect_type: "greedy",
    illust: "",
    effect(G, ctx, player) {
      if (player.has_tempura === true) {
        player.score += 3;
      }
      else {
        player.score += 1;
        player.has_tempura = true;
      }
    },
  },

{
    name: "汉堡",
    desc: "你的弃牌堆中每有2张牌，就获得1分",
    has_fruit: true,
    effect_type: "greedy",
    illust: "",
    effect(G, ctx, player) {
      let len = player.discard.length;
      player.score += Math.floor(len / 2);
    },
  },

{
    name: "相机",
    // desc: "获得1分，场上每有1个已出局的玩家，就再得1分",
    desc: "上家和下家每有一个已出局的玩家，获得2分",
    // has_fruit: true,
    effect_type: "greedy",
    illust: turtle_img,
    effect(G, ctx, player) {
      let idx = G.players.indexOf(player);
      let upper_idx = (idx + 1) % 4;
      let lower_idx = (idx + 3) % 4;
      let upper_player = G.players[upper_idx];
      let lower_player = G.players[lower_idx];
      if (upper_player.out === true) {
        player.score += 2;
      }
      if (lower_player.out === true) {
        player.score += 2;
      }
      // player.score += 1 + G.players.filter(p => p.out).length;
      // player.score += G.players.filter(p => p.out).length > 0? 2 : 0;
    },
  },

{
    name: "打印机",
    desc: "你每有1张存档，获得2分",
    has_fruit: true,
    effect_type: "greedy",
    illust: printer_img,
    effect(G, ctx, player) {
      player.score += player.hand.length * 2;
    },
  },

  {
    name: "大打印机",
    desc: "你每有1张存档，获得3分",
    has_fruit: true,
    effect_type: "greedy",
    illust: big_printer_img,
    is_reinforced: true,
    effect(G, ctx, player) {
      player.score += player.hand.length * 3;
    },
  },

{
    name: "苍蝇",
    desc: "如果你拥有水果，则失去3分，否则获得1分",
    has_fruit: false,
    effect_type: "topdown",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/322/fly_1fab0.png",
    effect(G, ctx, player) {
      let fruit = player.entities.find(x => typeof x == "object");
      if (fruit != undefined) {
        player.score -= 2;
      }
      else {
        player.score += 1;
      }
    },
  },

{
    name: "上传",
    desc: "如果你的存档中有牌，则获得2分",
    has_fruit: true,
    effect_type: "greedy",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/twitter/282/cloud_2601-fe0f.png",
    effect(G, ctx, player) {
      if (player.hand.length > 0) {
        player.score += 2;
      }
      // else {
        // move(player.deck, player.hand);
        // move(player.deck, player.hand);
      // }
    },
  },

{
    name: "加速",
    desc: "弃掉牌堆顶的1张牌，并执行其2次",
    // has_fruit: true,
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/racing-car_1f3ce-fe0f.png",
    illust: plane_img, 
    effect_type: "greedy",
    effect(G, ctx, player) {
      let card = move(player.deck, player.discard);
      if (card != undefined && card.effect != undefined) {
        log_msg(G, ctx, <span>执行了 {card.name} 两次</span>);
        card.effect(G, ctx, player);
        card.effect(G, ctx, player);
      }
    },
  },
  {
    name: "拆弹",
    desc: "查看牌堆顶的1张牌，如果是炸弹，将其弃掉并获得2分",
    has_fruit: true,
    effect_type: "protective",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/google/263/wrench_1f527.png",
    effect(G, ctx, player) {
      let card = player.deck[0];
      if (card != undefined) {
        log_msg(G, ctx, <span>使用拆弹翻开 {card.name}</span>);
        if (card.name == "炸弹") {
          move(player.deck, player.discard);
          player.score += 2;
        }
        else {
          return;
        }
      }
    }
  },
  {
    name: "引爆",
    desc: "如果你至少有6分，直接出局，否则获得1分",
    effect_type: "topdown",
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/fire_1f525.png",
    illust: fire_img,
    effect(G, ctx, player) {
      // let discarded = G.deck.slice(0, 2);
      // player.deck = player.deck.slice(2);
      // player.discard = [...discarded, ...player.discard];
      // // log_msg(G, ctx, <span>因为引爆弃掉了 {discarded.map(x => <span>{x.name} </span>)}</span>);
      // if (discarded.map(x => x.name).includes("炸弹")) {
      //   out(player);
      // }
      // else {
      //   player.score += 2;
      // }
      if (player.score >= 6) {
        // out(player);
      }
      else {
        player.score += 1;
      }
    }
  },

  {
    name: "机会",
    desc: "将2张山牌放到牌库顶",
    effect_type: "topdown",
    illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/game-die_1f3b2.png",
    effect(G, ctx, player) {
      player.deck = [...G.deck.slice(0,2), ...player.deck];
      G.deck = G.deck.slice(2);
    }
  },

  {
    name: "观星",
    desc: "查看牌库顶的2张牌",
    effect_type: "protective",
    has_fruit: true,
    illust: zoom_img,
    card_id: 4,
    effect(G, ctx, player) {
      let top_cards = player.deck.slice(0,2);
      if (top_cards.map((card: ICard) => card.name).includes("炸弹")) {
        if (player.entities.includes("skip") && player.is_ai) {
          let skip_idx = player.entities.indexOf("skip");
          player.entities[skip_idx] = "shield";
        }
      }
  }
},
{
    name: "观星得分",
    desc: "查看牌库顶的2张牌，获得2分",
    effect_type: "protective",
    has_fruit: true,
    // fruit: 1,
    illust: zoom_score_img,
    is_reinforced: true,
    effect(G, ctx, player) {
      player.score += 1;
      let top_cards = player.deck.slice(0,2);
      if (top_cards.map((card: ICard) => card.name).includes("炸弹")) {
        if (player.entities.includes("skip") && player.is_ai) {
          let skip_idx = player.entities.indexOf("skip");
          player.entities[skip_idx] = "shield";
        }
      }
  }
},

{
    name: "大观星",
    desc: "查看牌库顶的3张牌",
    effect_type: "protective",
    has_fruit: true,
    illust: big_zoom_img,
    is_reinforced: true,
    effect(G, ctx, player) {
      let top_cards = player.deck.slice(0,3);
      if (top_cards.map((card: ICard) => card.name).includes("炸弹")) {
        if (player.entities.includes("skip") && player.is_ai) {
          let skip_idx = player.entities.indexOf("skip");
          player.entities[skip_idx] = "shield";
        }
      }
  }
},

  {
    name: "果汁",
    desc: "如果你拥有水果，则获得2分",
    effect_type: "greedy",
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/cup-with-straw_1f964.png",
    illust: juice_img,
    card_id: 5,
    has_fruit: true,
    effect(G, ctx, player) {
      let fruit_types = player.entities.map(fruit => {
        if (typeof fruit == "object") {
          return fruit.fruit;
        }
        else {
          return undefined;
        }
      });
      let fruit_set = new Set(fruit_types.filter(x => x !== undefined));
      player.score += fruit_set.size * 2;
      // if (fruit_set.size > 0) {player.score += 2;}
    }
  },
{
    name: "大果汁",
    desc: "如果你拥有水果，则获得2分",
    effect_type: "greedy",
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/cup-with-straw_1f964.png",
    illust: "",
    has_fruit: true,
    is_reinforced: true,
    effect(G, ctx, player) {
      // player.score += 2;
      let fruit_types = player.entities.map(fruit => {
        if (typeof fruit == "object") {
          return fruit.fruit;
        }
        else {
          return undefined;
        }
      });
      let fruit_set = new Set(fruit_types.filter(x => x !== undefined));
      player.score += fruit_set.size * 3;
    }
  },

  {
    name: "果汁得分",
    desc: "如果你拥有水果，则获得2分",
    effect_type: "greedy",
    // illust: "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/240/apple/271/cup-with-straw_1f964.png",
    illust: sword_img,
    has_fruit: true,
    // fruit: 2,
    is_reinforced: true,
    effect(G, ctx, player) {
      player.score += 1;
      let fruit_types = player.entities.map(fruit => {
        if (typeof fruit == "object") {
          return fruit.fruit;
        }
        else {
          return undefined;
        }
      });
      let fruit_set = new Set(fruit_types.filter(x => x !== undefined));
      player.score += (fruit_set.size>0)?2:0;
    }
  },

];